<?php
include_once 'include.php';
$total = sql_count('lyy_ziliao');#总行数
$curr = isset($_REQUEST['curr'])?$_REQUEST['curr']:1;#当前页
$limit = 10;#每页多少行
$page = ceil($total/$limit);#总共有多少页
$offset = ($curr-1)*$limit;
$sql = "select a.id,a.title,a.type,a.file_url,b.username from lyy_ziliao a 
JOIN lyy_member b ON a.uid=b.id limit $offset,$limit";
$res = mysqli_query(conn(),$sql);
$lists = mysqli_fetch_all($res,MYSQLI_ASSOC);#资料列表
?>
<!DOCTYPE html>
<html>
<head>
    <?php include_once 'common_js_css.php'?>
	<link rel="stylesheet" type="text/css" href="css/kejian.css">
</head>
<body marginheight="0">
	<div class="cont" style="height: 910px">
        <div class="flash">
            <span><h1>课程课件及动画</h1></span>
        </div>
        <div class="list">
            <ul>
                <li><a href="#" onclick="ppt()" >课程课件</a></li>
                <li><a href="#" onclick="swf()" >课程动画</a></li>
            </ul>
        </div>
        <hr style="height:1px;border:none;border-top:2px solid blue;" />
        <form name="form2" method="post" action="">
            <table width="990"  class="ta"  style="border-collapse:separate; border-spacing:0px 0px;">
                <thead>
                <tr class="tr1" height="40">
                    <td width="50" align="center" valign="middle">序号</td>
                    <td width="300" align="center">课件名称</td>
                    <td width="200" align="center">课件类型</td>
                    <td width="100" align="center">授课老师</td>
                    <td width="250" align="center">课件下载</td>
                </tr>
                </thead>
                <tbody id="ppt">
                <?php foreach ($lists as $list): ?>
                    <?php if ($list['type']==1): ?>
                        <tr height="60">
                            <td align="center" valign="middle"><?php echo $list['id']; ?></td>
                            <td align="center"><?php echo $list['title']; ?></td>
                            <td align="center">PPT</td>
                            <td align="center"><?php echo $list['username']; ?></td>
                            <td align="center"><p><a href="<?php echo $list['file_url']; ?>">课件下载</a></p></td>
                        </tr>
                    <?php endif; ?>
                <?php endforeach; ?>
                </tbody>
                <tbody id="swf" style="display: none">
                <?php foreach ($lists as $list): ?>
                    <?php if ($list['type']==2): ?>
                        <tr height="60">
                            <td align="center" valign="middle"><?php echo $list['id']; ?></td>
                            <td align="center"><?php echo $list['title']; ?></td>
                            <td align="center">swf</td>
                            <td align="center"><?php echo $list['username']; ?></td>
                            <td align="center"><p><a href="<?php echo $list['file_url']; ?>">课件下载</a></p></td>
                        </tr>
                    <?php endif; ?>
                <?php endforeach; ?>
                </tbody>
                <tr height="40">
                    <td colspan="5" align="center">
                        <!--显示分页，只有一页，即不显示分页-->
                        <?php if($total>$limit){echo showPage($curr,$page);}?>
                        <input name="Submit2" class="print" type="button" onClick="javascript:window.print();" value="打印本页" />
                    </td>
                </tr>
            </table>
        </form>
    </div>
<script>
    function ppt(){
        var c1=document.getElementById("ppt");
        var c2=document.getElementById("swf");
        c1.style.display='';
        c2.style.display='none';
    }
    function swf(){
        var c1=document.getElementById("ppt");
        var c2=document.getElementById("swf");
        c1.style.display='none';
        c2.style.display='';
    }
</script>
</body>
</html>